fix: process members in SCIM Groups POST through mapping table#62
fix: process members in SCIM Groups POST through mapping table#62TerrifiedBug merged 1 commit intomainfrom
Conversation
POST /Groups was creating the ScimGroup record but completely ignoring body.members. When the IdP sends a group with its member list during sync, members were never processed through the mapping table, so users never got assigned to their mapped teams. Now both the create and adopt paths call applyGroupMembers which looks up the group's mappings and creates TeamMember records for each member.
Greptile SummaryThis PR fixes a gap in the SCIM Key observations:
Confidence Score: 4/5
Sequence DiagramsequenceDiagram
participant IdP
participant POST /Groups
participant DB
participant applyGroupMembers
participant loadGroupMappings
participant applyMappedMemberships
IdP->>POST /Groups: POST { displayName, members[] }
POST /Groups->>DB: findUnique(ScimGroup, displayName)
alt group already exists (adopt path)
DB-->>POST /Groups: existing group
POST /Groups->>DB: update externalId (if changed)
POST /Groups->>applyGroupMembers: (displayName, members)
applyGroupMembers->>loadGroupMappings: load all mappings from SystemSettings
loadGroupMappings-->>applyGroupMembers: GroupMapping[]
applyGroupMembers->>applyGroupMembers: getMappingsForGroup(mappings, displayName)
alt no mappings for this group
applyGroupMembers-->>POST /Groups: return (no-op)
else mappings found
applyGroupMembers->>DB: $transaction { for each member }
loop each member.value
DB-->>applyGroupMembers: user.findUnique(id)
applyGroupMembers->>applyMappedMemberships: (tx, userId, groupMappings)
applyMappedMemberships->>DB: findUnique(TeamMember)
alt member not in team
applyMappedMemberships->>DB: teamMember.create
else role upgrade needed
applyMappedMemberships->>DB: teamMember.update(role)
end
end
end
POST /Groups->>DB: writeAuditLog(scim.group_adopted)
POST /Groups-->>IdP: 200 OK
else group does not exist (create path)
DB-->>POST /Groups: null
POST /Groups->>DB: scimGroup.create(displayName, externalId)
POST /Groups->>applyGroupMembers: (displayName, members)
Note over POST /Groups,applyGroupMembers: ⚠ separate transaction — not atomic with create
applyGroupMembers->>loadGroupMappings: load mappings
loadGroupMappings-->>applyGroupMembers: GroupMapping[]
applyGroupMembers->>DB: $transaction { for each member }
POST /Groups->>DB: writeAuditLog(scim.group_created)
POST /Groups-->>IdP: 201 Created
end
|
|
@greptile review |
Summary
/Groupswas creating the ScimGroup record but ignoringbody.membersentirelyapplyGroupMembers()which looks up the group's mappings and creates TeamMember records for each memberTest plan